<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="ACTIONS_LIST_COLLECTION_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="ACTIONS_GRID" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="FOLDERS_COLLECTION_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="CURRENT_PATH_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="HTML_INPUT_TAG_ID_KEY" />
<atleap:constants className="com.blandware.atleap.common.Constants" var="ADMIN_CSS_THEME"/>
<html:html xhtml="true">
    <head>
        <!-- HTTP 1.1 -->
        <meta http-equiv="Cache-Control" content="no-store"/>
        <!-- HTTP 1.0 -->
        <meta http-equiv="Pragma" content="no-cache"/>
        <!-- Prevents caching at the Proxy Server -->
        <meta http-equiv="Expires" content="0"/>

        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <c:set var="ctxPath" value="${pageContext.request.contextPath}" scope="request"/>

        <title><atleap:message key="core.actionPage.listActions.title" /></title>
        <link rel="stylesheet" type="text/css" href="<atleap:rewriteUrl href="/styles/theme/${appConfig[ADMIN_CSS_THEME]}/theme.css"/>" />
        <script language="javascript" src="<atleap:rewriteUrl href="/scripts/core/klayers.js"  />"></script>
        <script language="javascript" src="<atleap:rewriteUrl href="/scripts/core/global.jsp"  />"></script>
    </head>
    <body>
        <div width="90%" align="right">
            <form action="javascript:window.close();">
                <input type="submit" class="button" style="margin-top: 5px; margin-bottom: 0px;" value="<atleap:message key="core.commons.buttons.close" />" />
            </form>
        </div>
        <c:set var="inputId" value="${sessionScope[pageScope.HTML_INPUT_TAG_ID_KEY]}" />
		<c:set value="${requestScope[pageScope.CURRENT_PATH_KEY]}" var="currentPath" />
		<c:set var="path" value="/" />
		<c:if test="${currentPath.numberOfFolders> 1}">
			<atleap:iterator items="${currentPath.folders}" var="folder" end="${currentPath.numberOfFolders - 2}">
				<atleap:rewriteUrl action="/core/actionPage/listActions"  var="folderLink">
					<atleap:param name="currentFolder" value="${folder.fullPath}" />
				</atleap:rewriteUrl>
				<c:set var="folderLink" value="<a href=\"${folderLink}\">${folder.name}</a>" />
	            <c:set var="path" value="${path}${folderLink}/" />
            </atleap:iterator>
		</c:if>
		<c:if test="${currentPath.numberOfFolders> 0}">
			<c:set var="path" value="${path}${currentPath.lastFolder.name}/" />
		</c:if>
        <atleap:grid name="${pageScope.ACTIONS_GRID}" pageSize="8" pageUrl="${pageContext.request.contextPath}/core/actionPage/listActions.do">
            <div class="hardCodedEntities">
                <table border="0" class="grid"  align="center">
                    <thead>
                        <tr>
                            <th colspan="2">
                                <atleap:message key="core.commons.currentPath" arg0="${path}" />
                            </th>
                        </tr>
                        <tr>
                            <th>
                                <atleap:column fieldName="uri" fieldKey="core.page.form.uri">
                                    <atleap:sort rowIterators="actionIterator">
                                        <atleap:message key="${fieldKey}" />
                                        <atleap:sortAsc>
                                            <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/ascSort.gif" />"  />
                                        </atleap:sortAsc>
                                        <atleap:sortDesc>
                                            <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/grid/descSort.gif" />"  />
                                        </atleap:sortDesc>
                                    </atleap:sort>
                                </atleap:column>
                            </th>
                            <th width="20">
                                <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/spacer.gif" />" border="0"  />
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <atleap:contextMenu var="folderMenuId">
                            <atleap:rowsIterator tagId="folderIterator" var="folder" collection="${requestScope[pageScope.FOLDERS_COLLECTION_KEY]}" oddClass="oddRow" evenClass="evenRow">
                                <atleap:itemSet>
                                    <atleap:rewriteUrl action="core/actionPage/listActions" var="defaultUrl">
                                        <atleap:param name="currentFolder" value="${folder.fullPath}" />
                                    </atleap:rewriteUrl>
                                    <tr class="${rowClass}" oncontextmenu="return showContextMenu(${folderMenuId}, event, ${indexId});" onclick="dispatchGridTrClick(event, this, &#039;${defaultUrl}&#039;);">
                                        <td colspan="2">
                                            <atleap:link action="core/actionPage/listActions">
                                                <atleap:param name="currentFolder" value="${folder.fullPath}" />
                                                /<c:out value="${folder.name}" escapeXml="true" />
                                            </atleap:link>
                                        </td>
                                        <atleap:item includeInPage="false">
                                            <atleap:itemEnabled>
                                                <atleap:message key="core.commons.folders.openFolder" var="openFolderMsg" />
                                                <atleap:itemLink action="core/actionPage/listActions" title="${openFolderMsg}">
                                                    <atleap:param name="currentFolder" value="${folder.fullPath}" />
                                                    <atleap:itemLabel>
                                                        ${openFolderMsg}
                                                    </atleap:itemLabel>
                                                </atleap:itemLink>
                                            </atleap:itemEnabled>
                                        </atleap:item>
                                    </tr>
                                </atleap:itemSet>
                            </atleap:rowsIterator>
                            <atleap:rowsIterator tagId="actionIterator" collection="${sessionScope[pageScope.ACTIONS_LIST_COLLECTION_KEY]}" var="action" oddClass="oddRow" evenClass="evenRow">
                                <tr class="${rowClass}" onclick="if (whetherNeedToRedirect(event, this)) { pasteSelected(&#039;${currentPath}${action}&#039;, window.opener, &#039;${inputId}&#039;); window.close();}">
                                    <td width="350"><c:out value="${action}" escapeXml="true" /></td>
                                    <td width="20" height="20" align="center" valign="middle" class="defaultCursorCell">
                                        <a href="javascript:void(0)" onclick="pasteSelected(&#039;${currentPath}${action}&#039;, window.opener, &#039;${inputId}&#039;); window.close();">
                                            <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/select.gif" />" border="0" alt="<atleap:message key="core.commons.buttons.select" />" title="<atleap:message key="core.commons.buttons.select" />"  />
                                        </a>
                                    </td>
                                </tr>
                            </atleap:rowsIterator>
                        </atleap:contextMenu>
                        <atleap:noRows>
                            <tr>
                                <td align="center" colspan="2" class="tfoot">
                                    <em><atleap:message key="core.commons.nothingToShow"/></em>
                                </td>
                            </tr>
                        </atleap:noRows>
                    </tbody>
                    <tfoot>
                        <tr>
                            <atleap:pager pageCount="10">
                                <td align="center" colspan="2">
                                    <atleap:message key="core.grid.pager.title" />&nbsp;
                                    <atleap:firstPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/first.gif" />" border="0" alt="<atleap:message key="core.grid.pager.first"/>" title="<atleap:message key="core.grid.pager.first"/>" /></atleap:firstPage>
                                    <atleap:prevPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/prev.gif" />" border="0" alt="<atleap:message key="core.grid.pager.prev"/>" title="<atleap:message key="core.grid.pager.prev"/>" /></atleap:prevPage>
                                    <atleap:pagesIterator>
                                        <atleap:page>${pageNumber}&nbsp;</atleap:page>
                                        <atleap:currentPage><b>${pageNumber}</b>&nbsp;</atleap:currentPage>
                                    </atleap:pagesIterator>
                                    <atleap:nextPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/next.gif" />" border="0" alt="<atleap:message key="core.grid.pager.next"/>" title="<atleap:message key="core.grid.pager.next"/>" /></atleap:nextPage>
                                    <atleap:lastPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/last.gif" />" border="0" alt="<atleap:message key="core.grid.pager.last"/>" title="<atleap:message key="core.grid.pager.last"/>" /></atleap:lastPage>
                                </td>
                            </atleap:pager>
                        </tr>
                    </tfoot>
                </table>
            </atleap:grid>
        </div>
    </body>
</html:html>


